package com.jian.ecommercial.controller;


import com.jian.ecommercial.domain.StockUser;
import com.jian.ecommercial.service.StockUserService;
import com.jian.ecommercial.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/stockuser")
public class StockUserController extends BaseController{
    @Autowired
    StockUserService userService;

    @RequestMapping("/login")
    public JsonResult login(String username, String password, HttpSession session){
        System.out.println(username);
        System.out.println(password);
        StockUser user = userService.login(username, password);

        session.setAttribute("uid",user.getUsername());
        return new JsonResult<StockUser>(200,user);
    }

}
